<?
require_once  '../classes/ConnectionDB.php';
require_once  '../classes/ClasseDataManager.php';
require_once  '../classes/TestDataManager.php';
require_once  '../bean/Domanda.php';

$connection =ConnectionDB::getInstance()->connectToDB();
$codiceTest = $_GET["codiceTest"];
$test = TestDataManager::getInstance()->getTestByCodice($connection, $codiceTest);
$listaClassi = ClasseDataManager::getInstance()->getClassi($connection);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Nuova sottomissione Test - step 1 - </title>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/prototype.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/scriptaculous/effects.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/glassbox/glassbox.js" type="text/javascript"></script>
        <style type="text/css">
            @import url("../css/style.css");

            #testForm {
                padding-top: 3%;
                margin-left: -5px;
            }

            #testFormCont
            {
                padding-left: 2%;
                padding-top: 10%;
            }

            #testFormCont table
            {

            }



        </style>
        <script type="text/javascript">
            path_to_root_dir = "../glassboxLatest/glassbox.2.0.0/";
            var listaDomande;
            var numItem=10;
            var currentIndex=0;

            window.onload = function()
            {
                var testForm = new GlassBox();
                testForm.init( 'testForm', '840px', '390px', 'hidden','',true, false);
                testForm.ipos();
                testForm.appear();
            }

            function generaKey()
            {
                N_Caratteri = 10;
                Stringa = "";
                for (I=0;I<N_Caratteri;I++)
                {
                    do
                    {
                        N = Math.floor(Math.random()*74)+48;
                    }
                    while(!(((N >= 48) && (N <= 57)) || ((N >= 65) && (N <= 90)) || ((N >= 97) && (N <= 122))));

                    Stringa = Stringa+String.fromCharCode(N);
                }
                document.getElementById('key').value=Stringa;
                document.getElementById('keyText').innerHTML=Stringa;
            }
        </script>
    </head>
    <body>
        <?php include '../portal/header.php';?>
        <center>
            <div id="testForm">
                <div id="testFormCont">
                    <form method="POST" action="liveTestRes.php">
                        <input type="hidden" name="codiceTest" value="<?= $test->getCodice() ?>" />
                        <input type="hidden" name="nomeTest" value="<?= $test->getNome() ?>" />
                        <input type="hidden" name="ore" value="<?= $test->getOre() ?>" />
                        <input type="hidden" name="minuti" value="<?= $test->getMinuti() ?>" />
                        <input type="hidden" name="key" id="key" value=""  />
                        
                        <table cellpadding="13">
                            <tr>
                                <th>Nome test : </th>
                                <td><?= $test->getNome() ?></td>
                                <td><a href="../report/testQuestions.php?codiceTest=<?= $test->getCodice() ?>">Lista domande</a></td>
                            </tr>
                            <tr>
                                <th>Tempo richiesto : </th>
                                <td>
                                    <table>
                                        <tr>
                                            <td><?= $test->getOre() ?> hh : <?= $test->getMinuti() ?> mm</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <th>Sottometti a classe : </th>
                                <td>
                                    <select name="classe" id="classe">
                                        <?
                                        for($j=0; $j<count($listaClassi); $j++)
                                        {
                                            ?>
                                        <option value="<?= $listaClassi[$j]->getCodice() ?>"><?= $listaClassi[$j]->getClasse() ?>&nbsp;<?= $listaClassi[$j]->getSezione() ?>&nbsp;<?= $listaClassi[$j]->getDescrizioneIndirizzo() ?>
                                        </option>

                                            <? } ?>

                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <th>Key generata : </th>

                                <td><label id="keyText"></label></td>
                            </tr>
                            <script>generaKey();</script>

                            <tr>
                                <td colspan="2"></td>
                                <td><input type="submit" value="Continua" /></td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </center>
    </body>
</html>
